<template>
	<view class="centerMessage" v-if="list.length > 0">
		<view class="centerMessageLi" @click="cli_li(item, index)" v-for="(item,index) in list" :key="index">
			<view class="centerMessageLiLeft">
				<image class="centerMessageLiLeftImg" src="https://www.zzzsyh.com/applets/agent/agent/news.png" mode=""></image>
			</view>
			<view class="centerMessageLiRight">
				<view class="centerMessageLiRightTop">
					<text class="centerMessageLiRightTopTxt1 font_blod">系统通知</text>
					<text class="centerMessageLiRightTopTxt2">{{item.createTime}}</text>
				</view>
				<view class="centerMessageLiRightBtm">
					<view class="centerMessageLiRightBtmLeft">
						{{item.messageContent}}
					</view>
					<view class="centerMessageLiRightBtmRight">
						<view class="centerMessageLiRightBtmRightBox" v-if="item.messageStatus == 0">
							
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
	<view class="centerMessage flex" v-else>
		<view class="yPopNone">
			<image class="yPopNoneImg" src="https://www.zzzsyh.com/applets/agent/factory/23.png" mode="">
			</image>
			<view class="yPopNoneTxt">
				暂无消息通知~
			</view>
		</view>
	</view>
</template>

<script>
	import allapi from '../api/index.js'
	export default {
		data() {
			return {
				agentId: uni.getStorageSync('agentId'),
				list: []
			}
		},
		mounted() {
			this.getMessageByAgentId()
		},
		methods: {
			// 点击阅读消息
			cli_li (item, index) {
				this.updateMessageById(item.id)
			},
			updateMessageById (id) {
				uni.request({
					url: allapi.updateMessageById,
					data: {
						id: id
					},
					success: (res) => {
						console.log(res);
						this.getMessageByAgentId()
					}
				})
			},
			// 获取消息列表
			getMessageByAgentId () {
				uni.request({
					url: allapi.getMessageByAgentId,
					data: {
						agentId: this.agentId
					},
					success: (res) => {
						console.log(res);
						this.list = res.data.data
					}
				})
			}
		}
	}
</script>

<style scoped>
	.flex {
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.centerMessage {
		position: absolute;
		width: 100%;
		height: 100%;
		background: #FFFFFF;
		overflow: auto;
	}
	.centerMessageLi {
		padding: 36rpx 32rpx;
		display: flex;
	}
	.centerMessageLiLeftImg {
		width: 88rpx;
		height: 88rpx;
	}
	.centerMessageLiRight {
		margin-left: 24rpx;
		flex: 1;
	}
	.centerMessageLiRightTop {
		display: flex;
		justify-content: space-between;
		line-height: 40rpx;
	}
	.centerMessageLiRightTopTxt1 {
		font-size: 28rpx;
		color: #333333;
	}
	.centerMessageLiRightTopTxt2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #BBBBBB;
	}
	.centerMessageLiRightBtm {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 6rpx;
		line-height: 34rpx;
	}
	.centerMessageLiRightBtmLeft {		
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		flex: 1;
		margin-right: 32rpx;
	}
	.centerMessageLiRightBtmRight {
		width: 16rpx;
		height: 16rpx;
	}
	.centerMessageLiRightBtmRightBox {
		width: 16rpx;
		height: 16rpx;
		background: #EF691C;
		border-radius: 50%;
	}
</style>
